package com.definity.toolkit.ui.widget;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JProgressBar;

import com.definity.toolkit.ui.Body;

public class ProgressBar extends JProgressBar implements Widget<ProgressBar> {

	private static final long serialVersionUID = 2776028537220539385L;

	public ProgressBar() {

	}

	public ProgressBar(int orient, int min, int max) {
		super(orient, min, max);
	}

	public ProgressBar(int min, int max) {
		super(min, max);
	}

	public ProgressBar(int orient) {
		super(orient);
	}

	@Override
	public String id() {
		return getName();
	}

	@Override
	public ProgressBar id(String id) {
		setName(id);
		return this;
	}

	@Override
	public ProgressBar properties(Body<ProgressBar> body) {
		body.content(this);
		return this;
	}

	@Override
	public Color background() {
		return getBackground();
	}

	@Override
	public ProgressBar background(Color background) {
		setBackground(background);
		return this;
	}

	@Override
	public Color foreground() {
		return getForeground();
	}

	@Override
	public ProgressBar foreground(Color foreground) {
		setForeground(foreground);
		return this;
	}

	@Override
	public ProgressBar size(int width, int height) {
		setPreferredSize(new Dimension(width, height));
		return this;
	}
	
	@Override
	public Font font() {
		return getFont();
	}

	@Override
	public ProgressBar font(Font font) {
		setFont(font);
		return this;
	}
	
	public int min() {
		return getMinimum();
	}
	
	public ProgressBar min(int min) {
		setMinimum(min);
		return this;
	}

	public int max() {
		return getMaximum();
	}
	
	public ProgressBar max(int max) {
		setMaximum(max);
		return this;
	}
	
	public int orientation() {
		return getOrientation();
	}
	
	public ProgressBar orientation(int orientation) {
		setOrientation(orientation);
		return this;
	}

	public String text() {
		return getString();
	}
	
	public ProgressBar text(String text) {
		setStringPainted(text != null);
	
		setString(text);
		return this;
	}

	public int value() {
		return getValue();
	}
	
	public ProgressBar value(int value) {
		setValue(value);
		return this;
	}
	
	public boolean indeterminate() {
		return isIndeterminate();
	}
	
	public ProgressBar indeterminate(boolean indeterminate) {
		setIndeterminate(indeterminate);
		return this;
	}
	
}
